package com.icangya.DAO.impl;

import com.icangya.DAO.IRwUserAddressDAO;
import com.icangya.domain.RwUserAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class RwUserAddressDAOImpl extends  BaseDAO<RwUserAddress> implements IRwUserAddressDAO {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public List<RwUserAddress> getListByuserid(long userid) {

        String hql=" FROM RwUserAddress pi WHERE pi.userid = ? ";

        List<RwUserAddress> list = (List<RwUserAddress>) getHibernateTemplate().find(hql, userid);

        if (list != null && list.size() > 0){

            return list;

        }
        return null;

    }

    @Override
    public RwUserAddress getUserAddressById(long id) {
        String hql=" FROM RwUserAddress pi WHERE pi.id = ? ";

        List<RwUserAddress> list = (List<RwUserAddress>) getHibernateTemplate().find(hql, id);

        if (list != null && list.size() > 0){

            return list.get(0);

        }
        return null;
    }
}
